package org.openkanban.client.ui.presenter;

import org.openkanban.client.ui.board.ActivityView;
import org.openkanban.client.ui.board.KanbanView;
import org.openkanban.client.util.RootPanel;
import org.openkanban.shared.dto.StatusDto;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.smartgwt.client.util.SC;

public class RemoveKanbanRequestCallback implements RequestCallback {

    private KanbanView kanbanView;

    public RemoveKanbanRequestCallback(KanbanView kanbanView) {
	this.kanbanView = kanbanView;
    }

    @Override
    public void onResponseReceived(Request request, Response response) {
	StatusDto statusDto = new StatusDto(response.getText());
	if (statusDto.isCallSuccessfull()) {
	    ActivityView activityView = RootPanel.main.getBoard().getWhiteBoardView().getActivityViewById(kanbanView.getParentActivityId());
	    activityView.removeKanbanView(kanbanView.getKanbanDto().getKanbanId());
	} else {
	    SC.say("Error occured removing Kanban");
	}
    }

    @Override
    public void onError(Request request, Throwable exception) {
    }

}
